using System;

namespace Sedna.Core.Persistence
{
	/// <summary>
	/// attribute that should be used to mark up a method of a component that must be 
	/// executed within a valid transaction (usually a database transaction). A component that 
	/// has a method that is marked with this attribute need not implement <see cref="ISessionAware"/> 
	/// interface. However, this is a general and a recommended practice to do so, so as to allow the
	/// <see cref="PstInterceptor"/> to inject a valid NHibernate ISession into that component.
	/// Therefore, the Transactional attribute and ISessionAware interface are usually goes together.
	/// One should understand that, if a method only reads data from the underlying database, there is no
	/// need to mark that method as Transactional, it is enough either to mark it as Sessional or
	/// just implement the ISessionAware attribute by the enclosing component.
	/// If the <see cref="PstInterceptor"/> detects that an intercepted method call marked with this attribute,
	/// it either joins an existing transaction or starts one anew. In the latter case, if the invocation is successful,
	/// the newly opened transaction is committed by the <see cref="PstInterceptor"/>.
	/// In casy of any exception propagated up to the HbmInterceptor a current transaction (whether created within 
	/// that particular invocation or not) is rolled back and a corresponding NHibernate ISession is closed.
	/// 
	/// This attribute is mostly part supposed to be used in DAO and DomainService components.
	/// </summary>
	[AttributeUsage(AttributeTargets.Method)]
	public class TransactionalAttribute : Attribute
	{
	}
}
